<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>06_员工表录入</title>
</head>
<body>
<input type="text" placeholder="请输入员工姓名" id="i1"><br>
<input type="text" placeholder="请输入员工工资" id="i2"><br>
<input type="text" placeholder="请输入员工岗位" id="i3"><br>
<button onclick="addPlayer()">添加员工</button>
<hr>
<table border="1px" id="userT">
    <caption>员工表</caption>
    <tr>
        <th>姓名</th>
        <th>工资</th>
        <th>岗位</th>
    </tr>
</table>
</body>
<script>
    function addPlayer() {
        let uName = document.getElementById('i1').value;
        let uSalary = document.getElementById('i2').value;
        let uJob = document.getElementById('i3').value;
        console.log(uName, uJob, uSalary);
        let tr = document.createElement('tr');
        let tdName = document.createElement('td');
        let tdSalary = document.createElement('td');
        let tdJob = document.createElement('td');
        tdName.innerHTML = uName;
        tdSalary.innerHTML = uSalary;
        tdJob.innerHTML = uJob;
        tr.append(tdName, tdSalary, tdJob);
        console.log(tr);
        document.getElementById('userT').append(tr);
        let data = [{Name: uName}, {Salary: uSalary}, {Job: uJob}];
        console.log(data);
        document.getElementById('i1').innerHTML = '';
        document.getElementById('i2').innerHTML = '';
        document.getElementById('i3').innerHTML = '';

    }
</script>
</html>